<?php

namespace App\Models\Account;

use App\Models\BaseModel;

class UserCache extends BaseModel
{

    protected $table = 'user_caches';
    protected $fillable = ['user_id', 'cache', 'type', 'expired_at', 'data_scope'];
     protected $casts = ['cache' => 'array'];
     
    public function user()
    {
        return $this->belongsTo('App\Models\Account\User', 'user_id');
    }

    public function addCache($data)
    {
        $data['data_scope'] = $this->getDataScope();
        return $this->create($data);
    }

}
